package com.education.framework.application;

import java.util.List;

import org.springframework.context.ApplicationContext;

import com.education.domain.SysDictionary;
import com.education.domain.SysMenu;

public class ApplicationHelper implements IApplicationData {
	
	private List<SysDictionary> dictionaryList;
	private List<SysMenu> menuList;
	
	private static ApplicationHelper helper;
	
	private ApplicationHelper(){}
	
	public static IApplicationData getInstance(){
		if (helper == null){
			synchronized(ApplicationHelper.class){
				if(helper == null){
					helper = new ApplicationHelper();
				}
			}
		}
		return helper;
	}
	
	private ApplicationContext springContext = null;

	public ApplicationContext getSpringContext() {
		return springContext;
	}

	public void setSpringContext(ApplicationContext sc) {
		this.springContext = sc;
	}
	
	public Object getBean(String config){
		Object result;
		if (springContext == null ){
			result = null;
		}else{
			result = springContext.getBean(config);
		}
		return result;
	}

	public List<SysDictionary> getSysDictionaryList() {
		return dictionaryList;
	}

	public void setSysDictionaryList(List<SysDictionary> dictionaryList) {
		this.dictionaryList = dictionaryList;
	}
	
}